<template>
  <div>
    <city-header></city-header>
    <city-search :cities="cities"></city-search>
    <city-list :hotCities="hotCities" :cities="cities" :letter="letter"></city-list>
    <city-alphabet @change="handelLetterChange" :cities="cities"></city-alphabet>
  </div>
</template>
<script>
import axios from "axios";
import cityHeader from "./components/header";
import citySearch from "./components/Search";
import cityList from "./components/List";
import cityAlphabet from "./components/Alphabet";
export default {
  name: "city",
  components: {
    cityHeader,
    citySearch,
    cityList,
    cityAlphabet
  },
  data() {
    return {
      cities: {},
      hotCities: [],
      letter: ""
    };
  },
  mounted() {
    this.getCityInfo();
  },
  methods: {
    getCityInfo() {
      axios.get("api/city.json").then(res => {
        if (res.data.ret && res.data.data) {
          let data = res.data.data;
          this.cities = data.cities;
          this.hotCities = data.hotCities;
        }
      });
    },
    handelLetterChange(letter) {
      this.letter = letter;
    }
  }
};
</script>
<style>

</style>
